package com.koron.sinoprobe.web.ledger.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.annocation.CasUser;
import com.koron.common.core.interceptor.OrderByInterceptor;
import com.koron.sinoprobe.web.ledger.bean.query.SpBillQuery;
import com.koron.sinoprobe.web.ledger.bean.vo.SpBills;
import com.koron.sinoprobe.web.ledger.service.SpBillsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author twcao
 * @title: SpBillsController
 * @projectName GDH_EAM_V2
 * @description: 项目单据
 * @date 2022/4/2014:48
 */
@Slf4j
@RestController
@RequestMapping("/sp/project/bills/")
@Api(tags = "专项台账-项目单据")
public class SpBillsController {

    @Autowired
    private SpBillsService billsService;

    @GetMapping("/queryList")
    @ApiOperation("项目单据分页查询")
    public Response<PageInfo<SpBills>> queryList(@CasUser @ApiIgnore EamUser user, SpBillQuery query) {
        OrderByInterceptor.setOrderBy(query.getOrders());
        PageHelper.startPage(query.getPage(), query.getPageSize());
        List<SpBills> list = ADOConnection.runTask(user.getCurrDs(), billsService, "queryList", List.class, query);
        return Response.ok("查询成功", new PageInfo<>(list));
    }
}
